
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>修改密码</title>
<link rel="stylesheet" href='css/style.css' type="text/css">
</head>
<script type="text/javascript" src="js/WdatePicker.js"></script>
<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/sha1.js'></script>
<script type='text/javascript' src='js/public.js'></script>
<script type="text/javascript">
	function showuserkey() {
		var params = "user_keyName=userName&user_keyName=enterYear&user_keyName=major&user_keyName=userclass";
		new Ajax.Request("json/showUser_key", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				var res = request.responseText.evalJSON();

				if (res["result"]["userName"] == null)
					window.location.href = "login.html";
				document.getElementById("username").innerHTML = "欢迎 "
						+ res["result"]["userName"];
				document.getElementById("name").innerHTML = "姓名： "
						+ res["result"]["userName"];
				document.getElementById("uid").innerHTML = "学号： "
						+ res["result"]["uid"];
				document.getElementById("major").innerHTML = "专业： "
						+ res["result"]["major"];
				document.getElementById("userclass").innerHTML = "班级： "
					+ res["result"]["userclass"]+"班";
				document.getElementById("year").innerHTML = "入学年份： "
						+ res["result"]["enterYear"];
			},
			asynchronous : true
		});
		online();
	}
	

	function test() {

		var userPwd = hex_sha1(document.getElementById("userPwd").value);
		var userp = document.getElementById("userPwd").value;
		var newPwd = document.getElementById("newPwd").value;
		var newPwd1 = document.getElementById("newPwd1").value;
		var newp = hex_sha1(newPwd);
		if (userp == "" || newPwd == "" || newPwd1 == "") {
			alert("请将信息输入完整");
		}

		else if (newPwd == newPwd1) {
			var params = "newPwd=" + newp + "&oldPwd=" + userPwd;

			new Ajax.Request("json/altUser_Pwd", {
				method : "post",
				parameters : params,
				onComplete : function(request) {

					var res = request.responseText.evalJSON();

					if (res["result"]["flag"] == "true") {
						alert("密码已成功修改，如遗忘可通过管理老师修改");

					} else
						alert("失败，请确认学号没有被注册");
				},
				asynchronous : true
			});
		} else {
			alert("两次输入密码不一致，请重新确认");
		}

	}
</script>
<body onload="showuserkey()">

	<div id="header">

		<div id="nav">
			<ul
				style="float: left; padding: 0 20px; text-align: center; line-height: 50px;">
				<li style="float: left; font-size: 28px">经管院学术讲坛事务系统</li>
			</ul>
			<ul class="horizon">

				<li class="login">
					<ul class="vertical">
						<li class="userInfo" id="username">&nbsp;你好</li>
						<li class="userInfo2">
							<ul class="horizon">

								<li><a href="editorUser.html" target="_blank"
									style="text-decoration: none;">个人资料</a><br /> <a
									onclick="outline()" style="text-decoration: none;" href="#">注销</a></li>
							</ul>
						</li>
					</ul>
				</li>

			</ul>
		</div>




	</div>
	<div id="main">
		<div
			style="width: 21%; height: 660px; border-right: 3px #660033 solid; float: left; background-color: rgb(242, 247, 252);"></div>
		<div style="width: 78%; font-size: 22px; float: right">
			<div style="margin-top: 0px; margin-left: 0px; height: 550px">
				<div
					style="margin-top: 180px; margin-left: 0px; float: left; width: 550px; height: 200px; font-size: 18px; border: 1px solid #CCC">
					<p style="margin-left: 100px;margin-top: 20px">
						基本信息(不可自行修改，可联系管理老师修改)
					</p>
					<p id="uid" style="margin-left: 100px; margin-top: 10px">学号：</p>
					<p id="name" style="margin-left: 100px;">姓名：</p>
					<p id="major" style="margin-left: 100px;">专业：</p>
					<p id="userclass" style="margin-left: 100px;">班级：</p>
					<p id="year" style="margin-left: 100px;">入学年份：</p>

				</div>
				<div
					style="margin-top: 180px; margin-left: 20px; float: left; border: 1px solid #CCC; height: 200px; width: 350px">
					<form method="post" style="font-size: 18px">
						旧密码:<br> <input type="password" id="userPwd" name="userPwd"
							size="30" style="height: 20px"><br> 新密码:<br> <input
							type="password" id="newPwd" name="newPwd" size="30"
							style="height: 20px"><br> 确认密码:<br> <input
							type="password" id="newPwd1" name="newPw1" size="30"
							style="height: 20px"><br> <br> <input
							type="button" value="修改" onclick="test()"
							style="border:1px solid; border-color:#CCC; height: 28px; width: 70px; font-size: 22px;">
					</form>
				</div>
			</div>
			<div style="font-size: 14px; margin-left: 100px;">
				<span id="online">当前在线人数:</span> <span style="margin-left: 150px">Copyright
					&copy; 2013 经济管理学院 北京市海淀区清华东路35号 邮编：100083</span>
			</div>
		</div>
	</div>

</body>
</html>